<template>
	<view>
	<view class="box"  v-for="logdata, index in dataList" :key="index">
		
		<view class="result">
			<view class="uploadTit">
				<view>时间：{{logdata.timer}}</view>
				<view>IP：{{logdata.ip}}</view>
			</view>
			<image class="resultImg" :src="getImgPath(logdata.img_path)" mode="aspectFit"></image>
			<view class="resultText" v-for="item, ind in getpartsData(logdata.result)" :key="ind">
				<view>检测：{{item.label}}， 置信度：{{item.conf}}</view>
				<view>分类：{{item.details}} </view>
			</view>
		</view>
		
		</view>
	</view>
</template>

<script>
	import {request} from"@/api/request.js"
	export default {
		data() {
			return {
				dataList:[],
				page_size: 10,
				page_num: 1,
				total:0
			};
		},
		onLoad() {
			this.getData()
		},
		onReachBottom(){
				// console.log('已触底');
				var pa = Math.ceil(this.total/this.page_size)
				// console.log(pa)
				if (this.page_num < pa){
					this.page_num += 1
					var res = request({
						url: '/DetectLogs',
						method:'GET',
						data:{page_size:this.page_size, page_num:this.page_num}
					}).then(res =>{
						// console.log(res)
						if (res.code == 1){
							
							// console.log(res)
							// this.msgList = res.data
							this.dataList = this.dataList.concat(res.data)
							// this.total = res.total
						}
					})
					
				}
				else{
					uni.showToast({
						title: '已到底',
						duration: 1000,
						icon:'none'
					});
				}
				
		    
		},
		methods:{
			getpartsData(data){
				// console.log(data)
				if(data){
					return JSON.parse(data)
				}
				return []
				
			},
			getImgPath(path){
				// console.log(config)
				return config.imgurl + path
			},
			
			
			getData(){
				var res = request({
					url: '/DetectLogs',
					method:'GET',
					data:{}
				}).then(res =>{
					console.log(res)
					if (res.code == 1){
						
						// console.log(res)
						this.dataList = res.data
						this.total = res.total
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.box{
		border-bottom: 1rpx dashed lightgray;
	}
	.result{
		width: 600rpx;
		// height: 400rpx;
		align-items: center;
		margin-left: auto;
		margin-right: auto;
		margin-top: 30rpx;
		margin-bottom: 30rpx;
		
		.resultImg{
			width: 600rpx;
			height: 400rpx;
			// height: 100%;
		}
		.uploadTit{
			font-size: 27rpx;
			margin-bottom: 20rpx;
		}
	}
</style>
